<template>
  <el-table
    :data="
      tableData
    "
    :stripe="stripe"
    :current-page.sync="currentPage"
    style="width: 100%"
  >
  <el-table-column prop="cj" :label="firstName" width="180">
  </el-table-column>
   
   <el-table-column prop="num" :label="lableName">
	
	   </el-table-column>
  </el-table>
  <div class="pagination">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-sizes="[10,15, 20]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>
<script>
import Sever from "@/api/selfApi.js";
export default {
  props: ["depCode"],
  data() {
    return {
		firstName:"层级",
      lableName: "",
      stripe: true, //是否为斑马纹 table
      tableData: [],
      currentPage: 1,
      pagesize: 10,
      total: 0,
    };
  },
  methods: {
    handleSizeChange(val) {
      this.pagesize = val;
	   this.refreshData(this.depCode,this.currentPage,this.pagesize);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
	   this.refreshData(this.depCode,this.currentPage,this.pagesize);
    },
    async refreshData(depCode,currentPage,pagesize) {
      if (depCode == "") {
        depCode = "36%";
      }
     
        this.lableName = "人数";
    
      await Sever.smz
        .getSydwBzsChildDfp({ depCode: depCode,pageNum:currentPage,pageSize:pagesize})
        .then((res) => {
          if (res.code == 1) {
            if (res.data != null) {
				console.log(res.data);
              this.tableData = res.data.list;
              this.total = res.data.total;
            } else {
              this.tableData = [];
            }
          } else {
            console.log("getSydwBzsChildDfp接口出错！");
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
	
  },
  mounted() {
    this.$nextTick(() => {
		console.log(this.depCode);
	
      this.refreshData(this.depCode,this.currentPage,this.pagesize);
    });
  },
};
</script>
